package com.aggregate.pay.weixin;

import com.aggregate.pay.weixin.bean.OrderQueryData;
import com.aggregate.pay.weixin.bean.OrderQueryResult;
import com.aggregate.pay.weixin.bean.RefundData;
import com.aggregate.pay.weixin.bean.RefundNotifyData;
import com.aggregate.pay.weixin.bean.RefundQueryData;
import com.aggregate.pay.weixin.bean.RefundQueryResult;
import com.aggregate.pay.weixin.bean.RefundResult;
import com.aggregate.pay.weixin.bean.UnifiedOrderData;
import com.aggregate.pay.weixin.bean.UnifiedOrderResult;
import com.aggregate.pay.weixin.support.Client;
import com.aggregate.pay.weixin.support.Config;
import com.aggregate.pay.weixin.support.Factory;
import com.aggregate.pay.weixin.support.HttpClient;
import com.aggregate.pay.weixin.support.Merch;

/**
 * 微信官方支付接口工具类，相关配置和接口调用从此类开始
 * @author Moyq5
 * @date 2018年6月15日
 */
public abstract class WeixinApiFactory {

	public static void config(Config config, HttpClient httpClient) {
		Factory.setConfig(config);
		Factory.setHttpClient(httpClient);
	}
	
	@SuppressWarnings("unchecked")
	public static Client<UnifiedOrderData, UnifiedOrderResult> unifiedOrderClient(Merch info) {
		return (Client<UnifiedOrderData, UnifiedOrderResult>)Factory.getClient(WeixinApiType.UNIFIED_ORDER, info);
	}
	
	@SuppressWarnings("unchecked")
	public static Client<OrderQueryData, OrderQueryResult> orderQueryClient(Merch info) {
		return (Client<OrderQueryData, OrderQueryResult>)Factory.getClient(WeixinApiType.ORDER_QUERY, info);
	}

	@SuppressWarnings("unchecked")
	public static Client<RefundData, RefundResult> refundClient(Merch info) {
		return (Client<RefundData, RefundResult>)Factory.getClient(WeixinApiType.REFUND, info);
	}
	
	@SuppressWarnings("unchecked")
	public static Client<RefundQueryData, RefundQueryResult> refundQueryClient(Merch info) {
		return (Client<RefundQueryData, RefundQueryResult>)Factory.getClient(WeixinApiType.REFUND_QUERY, info);
	}

	@SuppressWarnings("unchecked")
	public static Client<String, RefundNotifyData> refundNotifyClient(Merch info) {
		return (Client<String, RefundNotifyData>)Factory.getClient(WeixinApiType.REFUND_NOTIFY, info);
	}

}
